package cn.innosmart.aq.bean;

import android.location.Location;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by David on 2015/9/16.
 */
public class FriendBean {
    private String id;
    private String nickName;
    //经纬度位置信息
    private double longitude;
    //经纬度位置信息
    private double latitude;
    private String headIcon;
    private String groupid;

    public String getGroupid() {
        return groupid;
    }

    public void setGroupid(String groupid) {
        this.groupid = groupid;
    }

    public String getHeadIcon() {
        return headIcon;
    }

    public void setHeadIcon(String headIcon) {
        this.headIcon = headIcon;
    }

    public FriendBean(){

    }
    public FriendBean(JSONObject jsonObject) {
        try {
            this.nickName = jsonObject.getString("nickname");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        try {
            this.id = jsonObject.getString("id");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        try {
            JSONObject jsonLocation = jsonObject.getJSONObject("location");
            this.latitude = jsonLocation.getDouble("latitude");
            this.longitude = jsonLocation.getDouble("longitude");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }


    public float getDistance(double olatitude, double olongitude) {
        float[] results = new float[3];
        Location.distanceBetween(olatitude, olongitude, latitude, longitude, results);
        return results[0];
    }
}
